package com.zzl.rabbitmq.work;

import com.rabbitmq.client.Channel;
import com.zzl.rabbitmq.utils.RabbitMqUtils;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * Title: Task01.class<br>
 * Description: <br>
 * Copyright (c)  2021    <br>
 * Create DateTime: 2021/7/1 15:52 <br>
 *
 * @author zhuangzhuangliang
 */
public class Task01 {

    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws  Exception{

        System.out.println(System.currentTimeMillis());
        Channel channel = RabbitMqUtils.getChannel();
        //声明队列
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);
        //发送消息
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String msg = scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,msg.getBytes(StandardCharsets.UTF_8));
            System.out.println("消息发送完毕");
        }
    }
}
